<%@ page contentType="text/html;charset=UTF-8" %>

<!DOCTYPE html>
<html>
<head>
	<title>图片单个录入案例-图片列表</title>
	<%@ include file="/common/import.jsp" %>
    <%@ include file="/common/meta.jsp" %>
	<script>
	    $(function(){
    	    loadAttas();
	    })
	
	var atta_list_do = '${ctx}/attachment/store/list!data.action';
	var set_main_dic_do = '${ctx}/attachment/store/setMainPicFlag.action';
		
	//加载附件列表
	function loadAttas(){
		$.ajax({
			  url: atta_list_do,
			  type:'POST',
			  cache: false,
			  data:'objId=${objId}&objType=${objType}&attaSort='+$("input[name='attaSort']:checked").val(),
			  success: function(data){
			    $('#results').html(data);
			  }
			});
	}
	
	//关闭
	function closeAdd(){
	  $('#saveDiv').window('close');
	}
	
	//修改
	function updAttaStore(id,regEname){		
		var url = '${ctx}/attachment/store/edit.action?id='+id+'&objId=${objId}&objType=${objType}';
		$('#saveFrame').attr("title",regEname);
		$('#saveFrame').attr("src",url);
		$('#saveDiv').window('open');
	}
		
	// 增加
	function addAttaStore(){
		$('#saveFrame').html('');			
		var url = '${ctx}/attachment/store/add.action?objId=${objId}&objType=${objType}&objType=${objType}';				
		$('#saveFrame').attr("title",'');
		$('#saveFrame').attr("src",url);
		$('#saveDiv').window('open');	
	}	
	
	//删除
	function delAttaStore(id,name){
		$.messager.confirm('确认','您确定要删除:<font color=red>'+name+'</font> ？',function(r){
			if(r){
				 $.ajax({
					type:'post',
					url:'${ctx}/attachment/store/del.action',
					data:'id='+id+'&attaSort='+$("input[name='attaSort']:checked").val(),
					dataType:'json',
					success:function(data){
					     if("T"==data.flag){
					     	$.messager.alert("删除结果",data.msg, "info");
					     	loadAttas();
					     }else{
					     	$.messager.alert("删除结果",data.msg, "error");
					     	loadAttas();
					     }
						},
					error:function(){
						 $.messager.alert("删除结果","未知异常", "error");
						}
					});
		 	}
	  	});
	}
	
		/**
		*设置为主题
		*/
		function setMainPic(sid,picName){
			$.messager.confirm('确认',
				'确定要图片: <font color=red>'+picName+'</font> 设置为标题图吗?',function(flag){  
			       if(flag){  
			          setMainPicDo(sid);
			       }  
			});
		}
	
	/**
	*设置为主题Do
	*/
	function setMainPicDo(sid){
		var d = {"id":sid,"objId":"${objId}","objType":"${objType}"};
		$.ajax({
		  url: set_main_dic_do,
		  type: 'POST',
		  cache: false,
		  data: d,
		  success: function(data){
		  	var oTxt = jQuery.parseJSON(data);
		    var mess = oTxt.msg;	
			var flag = oTxt.flag;
	 
			if(flag=="T"){
				$.messager.alert('提交结果','设置成功！', 'info',function(){
					loadAttas();
				});
			 }else{
				$.messager.alert('提交结果',mess, 'error',function(){
				});
			 }
			
		  }
		});
	}
	
	
	function clickAttaSort(type){
	   if(type=="0"){
	     window.location.href="${ctx}/attachment/store/list.action?objId=${objId}&objType=${objType}";
	   }
	}
	</script>
	<style>
	body,ul,p,div,img,li,a{margin:0;padding:0;border:0;font-family:"宋体";color:#000;font-size:12px;}
	.cls{clear:both; height:0px; line-height:0px; overflow:hidden; font-size:0px;}
	.picdiv ul{padding:10px;}
	.picdiv a{boder:none;}

	.picdiv p.name{line-height:20px; height:40px; width:75px; overflow:hidden; color:#000;}
	.tools a{color:#619FCF;}
	.pic_Store_form{padding:10px;}
	ul.sct li{float:left;padding:10px 20px 10px 0;text-align:center;width:128px;list-style-type:none}
	ul.sct li .tu{width:128px;height:122px;}
	.picdiv .btn_a {
	  background: url("${ctx}/pic/images/pic_btn_1.jpg") no-repeat scroll 0 0 transparent;
	  border: medium none;
	  color: #000000;
	  height: 23px;
	  line-height: 23px;
	  text-align: center;
	  width: 70px;
	}
	
	.picdiv a.ljx {
	  display: inline;
	  float: right;
	  height: 15px;
	  margin-right: 5px;
	  margin-top: 10px;
	  width: 13px;
	  cursor:pointer;
	}
	
	.picdiv a.btt {
	  margin-top:15px;
	  color: #0590DE;
	  display: block;
	  float: left;
	  cursor:pointer;
	  padding-right: 5px;
	  text-align: right;
	  width: 100px;
	}
	
	.picdiv a.btt1 {
	  margin-top:15px;
	  color: #DDDDDD;
	  display: block;
	  float: left;
	  cursor:default;
	  padding-right: 5px;
	  text-align: right;
	  width: 100px;
	}
	#preview_fake{
		/* 该对象用于在IE下显示预览图片
		*/
		filter:progid:DXImageTransform.Microsoft.apacheImageLoader(sizingMethod=scale);
	}
	#preview_size_fake{
		/* 该对象只用来在IE下获得图片的原始尺寸，无其它用途
		*/
		filter:progid:DXImageTransform.Microsoft.apacheImageLoader(sizingMethod=image);
		visibility:hidden;
	}
	#preview{
		/* 该对象用于在FF下显示预览图片
		*/
		width:200px;
		height:200px;
	}




</style>
</head>
<body>
<div style="padding:5px 0;">
<span>				  
 <input type="radio" name="attaSort" value="0"   onclick="clickAttaSort('0')" />&nbsp;附件
 <input type="radio" name="attaSort" value="1" checked=checked onclick="clickAttaSort('1')" />&nbsp;图片
</span>	&nbsp;&nbsp;
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add'" title="上传图片" onclick="javascript:addAttaStore();">上传图片</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-reload'" onclick="javascript:loadAttas();" >刷新列表</a>
	</div>

    <div id="results"  title="图片列表" class="easyui-panel" style="height:330px;" data-options="iconCls:'icon-save',collapsible:true,maximizable:true"></div>

<!-- 上传、修改窗口 -->
	<div id="saveDiv" class="easyui-window" title="图片上传" style="padding:5px;width: 550px;height:320px;" 	
    	iconCls="icon-edit" closed="true" maximizable="false" minimizable="false" collapsible="false">
   		<iframe frameborder="0"  id="saveFrame" height="100%" width="100%" scrolling="No" frameborder="0" ></iframe>
    </div>


</body>
</html>